package com.shiguiwu.langchain.service;


import cn.hutool.json.JSONUtil;
import com.shiguiwu.langchain.entity.Reservation;
import com.shiguiwu.langchain.mapper.ReservationMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

@Slf4j
@Service
public class ReservationService {
    @Autowired
    private ReservationMapper reservationMapper;

    //1.添加预约信息的方法
    public void insert(Reservation reservation) {
        log.info("预约信息保存 ===> {}", JSONUtil.toJsonStr(reservation));
        reservationMapper.insert(reservation);
    }

    //2.查询预约信息的方法(根据手机号查询)
    public Reservation findByPhone(String phone) {
        Example example = new Example(Reservation.class);
        example.createCriteria()
                .andEqualTo("phone", phone);
        return reservationMapper.selectOneByExample(example);
    }
}